package io.renren.modules.com.service.impl;

import io.renren.common.query.QueryTool;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.Pages;

import io.renren.modules.com.dao.DictDao;
import io.renren.modules.com.entity.DictEntity;
import io.renren.modules.com.service.DictService;


@Service("dictService")
public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity> implements DictService {

    @Override
    public Pages<DictEntity> queryPage(DictEntity dict) {
        QueryWrapper<DictEntity> qw = new QueryWrapper<DictEntity>();
        QueryTool.condition(qw, dict);
        IPage<DictEntity> page = this.page(
                new Query<DictEntity>().getPage(dict),
                qw
        );
        return new Pages<DictEntity>(page);
    }

    @Override
    public List<DictEntity> listAll(DictEntity dict) {
        QueryWrapper<DictEntity> qw = new QueryWrapper<DictEntity>();
        QueryTool.condition(qw, dict);
        return baseMapper.selectList(qw);
    }

    @Override
    public void deleteByCondition(DictEntity dict) {
        QueryWrapper<DictEntity> qw = new QueryWrapper<DictEntity>();
        QueryTool.condition(qw, dict);

        baseMapper.delete(qw);
    }

}